import {useSelector, useDispatch} from 'react-redux';
// import Types from 'local-types';
import {Dispatch} from 'redux';

// type ReduxStateKey = keyof Types.RootState;
export function useReduxState(key: any): any {
  return useSelector((state: any) => state[key]);
}

/**
 * 获取 dispatch 对象
 *
 * @example
 * const dispatch = useReduxDispatch();
 * dispatch(rootActions.userActions.onUpdateUserInfo({ nickname: 'test' }));
 */
export function useReduxDispatch() {
  return useDispatch<Dispatch<any>>();
}
